package com.ehotting.edsta.diagnosisPredict.feign;

import com.ehotting.eaf.core.web.domain.diagnosisPredict.PageDto;
import com.ehotting.eaf.core.web.domain.diagnosisPredict.Response;
import com.ehotting.edsta.diagnosisPredict.domain.dto.MaterialInfoDto;
import com.ehotting.edsta.diagnosisPredict.domain.dto.MaterialInfoSearchDto;
import com.ehotting.edsta.diagnosisPredict.feign.factory.MaterialFallbackFactory;
import org.apache.http.HttpResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 素材集feignClient
 */
@FeignClient(name = "modelManagerMaterial", url = "${request.url.prefix}/material-info",fallbackFactory = MaterialFallbackFactory.class)
public interface MaterialFeignService {

    /**
     * 填写信息
     * @return
     */
    @GetMapping(value = "/search")
    Response<PageDto<MaterialInfoDto>> materialInfoSearch(@RequestBody MaterialInfoSearchDto dto);

    /**
     * 文件上传保存
     * @return
     */
    @PostMapping(value = "/save-and-upload")
    Response<MaterialInfoDto> saveAndUpload(@RequestParam("file") MultipartFile file,
                                            @RequestParam("fileDesc") String fileDesc,
                                            @RequestParam("fileName") String fileName,
                                            @RequestParam("projectId") String projectId);

    /**
     * 我的数据库选择
     * @return
     */
    @PostMapping(value = "/save")
    Response<MaterialInfoDto> materialInfoSave(@RequestBody MaterialInfoDto dto);

    /**
     * 数据预览
     * @param fileId
     * @return
     */
    @GetMapping(value = "/viewfile")
    Response<List<String[]>> viewfile(@RequestParam("encoding") String encoding, @RequestParam("fileId") Long fileId);

    /**
     * 删除（批量）
     * @param ids
     * @return
     */
    @DeleteMapping(value = "/batch")
    Response<Boolean> batch(@RequestParam("idList") String ids);

    /**
     * 下载数据集
     * @param fileId
     * @return
     */
    @PostMapping(value = "/downloadfile")
    feign.Response downloadfile(@RequestParam("fileId") Long fileId);


    /**
     * 创建数据集
     * @return
     */
    @PostMapping(value = "/save-no-project")
    Response<MaterialInfoDto> saveNoProject(@RequestBody MaterialInfoDto dto);

    /**
     * 材料文件上传
     * @return
     */
    @PostMapping(value = "/upload-no-project/{id}")
    Response<MaterialInfoDto> uploadNoProject(@RequestParam("file") MultipartFile file, @PathVariable("id") Long id);

    /**
     * 下载模板
     * @param projectType
     * @return
     */
    @GetMapping(value = "/getUrl")
    feign.Response getUrl(@RequestParam("projectType") String projectType);
}